package com.sojpt.boot.controller.business.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
import com.sojpt.model.DicUser;

/**
 * Description: 本类用于
 * Created by JYN_LL on 2020/2/13 9:54
 */
public class LkyStudentUserAddValidator extends Validator {
    @Override
    protected void validate(Controller c) {

        DicUser dicUser = c.getModel(DicUser.class, "student");

        if(dicUser.get("USER_CODE") != null)
            validateString("student.USER_CODE", 0, 50, "msg", "账号（学号） 最多50个字符");

        validateRequired("student.USER_CODE", "msg", "请输入账号（学号）");

        if(dicUser.get("USER_NAME") != null)
            validateString("student.USER_NAME", 0, 50, "msg", "真实姓名 最多50个字符");

        validateRequired("student.USER_NAME", "msg", "请输入真实姓名");

        if(dicUser.get("PASSWD") != null)
            validateString("student.PASSWD", 3, 12, "msg", "密码 最多12个字符");

        validateRequired("student.PASSWD", "msg", "请输入密码");

        validateString("student.telphone",11,11, "msg", "请输入手机号");
        if(dicUser.get("id_card") != null)
            validateString("student.id_card", 0, 28, "msg", "身份证 最多28个字符");
        validateRequired("student.id_card", "msg", "请输入身份证");


    }

    @Override
    protected void handleError(Controller c) {
        c.renderJson();
    }
}
